﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Obra.Common;

namespace Obra.Sync
{
    public interface IFileSystemService
    {
        /// <summary>
        /// Compute the checksum of a file.
        /// </summary>
        /// <param name="path">
        /// Path to the file to compute the checksum of.
        /// </param>
        /// <param name="checksumAlgorithm">
        /// Algorithm to use for the checksum computation.
        /// </param>
        /// <returns>
        /// Checksum as hex digits, i.e. 0123456789abcdef
        /// </returns>
        string ComputeChecksum(string path, ChecksumAlgorithm checksumAlgorithm);

        /// <summary>
        /// Delete the specified file.
        /// </summary>
        /// <param name="path">
        /// File to delete.
        /// </param>
        void Delete(string path);

        /// <summary>
        /// Get the files in a directory.
        /// </summary>
        /// <param name="directory">
        /// The directory to query.
        /// </param>
        List<FileInfo> GetMediaFiles(string path);

        /// <summary>
        /// Return a function that returns a stream.
        /// </summary>
        /// <param name="path">
        /// File whose strea is returned.
        /// </param>
        /// <remarks>
        /// <para>
        /// The synchronization framework will most likely cause unnecessary 
        /// loads, which would cause the loading of streams.  Loading a stream
        /// every time is unnecessary, so lazily load the stream by wrapping it
        /// in a function.
        /// </para>
        /// </remarks>
        Func<Stream> LazyLoad(string path);

        /// <summary>
        /// Write the stream to the specified path.
        /// </summary>
        /// <param name="path">
        /// File to write the contents of the stream to.
        /// </param>
        /// <param name="stream">
        /// Data to write to the specified file.
        /// </param>
        void Write(string path, Stream stream);
    }
}
